package com.example.cardemo.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.example.cardemo.R
import com.example.cardemo.bean.ModellistBean
import com.example.cardemo.databinding.ItemModellistBinding

class ModellistAdapter(var ctx: Context, var mDatas: MutableList<ModellistBean.ResultBean>) : RecyclerView.Adapter<ModellistAdapter.BrandHolder>() {
    private val inflater = LayoutInflater.from(ctx)

    class BrandHolder(val binding: ItemModellistBinding) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BrandHolder {
        val binding: ItemModellistBinding = DataBindingUtil.inflate(inflater, R.layout.item_modellist, parent, false)
        return BrandHolder(binding)
    }

    override fun onBindViewHolder(holder: BrandHolder, position: Int) {
        val bean = mDatas[position]
        holder.binding.item = bean
    }

    override fun getItemCount(): Int {
        return mDatas.size
    }
}